import { isBoolean, isFunction, isUndefined } from "@/utils"

/**
 * 停用状态配置，默认为 false
 */
export interface DisbaledProps {
    disabled?: boolean | ((...args: any[]) => boolean)
}

/**
 * 是否禁用
 * @param props 配置
 * @param args 入参
 */
export function isDisabled(props: DisbaledProps, ...args: any[]): boolean {
    const { disabled } = props
    if (isUndefined(disabled)) {
        return false
    }
    if (isBoolean(disabled)) {
        return disabled as boolean
    }
    if (isFunction(disabled)) {
        return (disabled as Function)(...args)
    }
    console.log("禁用配置格式错误：%s", disabled)
    return true
}
